import {
  dictDataList,
} from "@/api/order";

// 入库单
export const Type_In = {
  // 入库类型
  type: async () => {
    const res = await dictDataList({
      dictType: "cwms_input_type",
    })
    return res.map((btn) => {
      return {
        name: btn.dictLabel,
        value: btn.dictValue,
        id: btn.id,
      };
    });
  },
  // 商品列表详细信息
  detailInfoList: () => {
    return [
      { name: "单价", value: "unitPrice", preUnit: "¥" },
      { name: "数量", value: "qty", afterUnit: 'unitName' },
      { name: "金额", value: "amount", preUnit: "¥" },
      { name: "备注", value: "remark" },
    ]
  },
  // 弹窗编辑
  options: () => {
    return [
      { name: "入库单价", value: "unitPrice", type: "step", unInteger: true, preUnit: "元/", unit: "unitName" },
      { name: "入库数量", value: "qty", type: "step", unit: 'unitName' },
      { name: "备注", value: "remark", type: "input" },
    ]
  }
}
// 出库单
export const Type_Out = {
  type: async () => {
    const res = await dictDataList({
      dictType: "cwms_output_type",
    })
    return res.map((btn) => {
      return {
        name: btn.dictLabel,
        value: btn.dictValue,
        id: btn.id,
      };
    });
  },
  // 商品列表详细信息
  detailInfoList: () => {
    return [
      { name: "单价", value: "unitPrice", preUnit: "¥" },
      { name: "数量", value: "qty", afterUnit: 'unitName' },
      { name: "金额", value: "amount", preUnit: "¥" },
      { name: "备注", value: "remark" },
    ]
  },
  options: () => {
    return [
      { name: "出库单价", value: "unitPrice", type: "step", unInteger: true, preUnit: "元/", unit: "unitName" },
      { name: "出库数量", value: "qty", type: "step", unit: 'unitName' },
      { name: "备注", value: "remark", type: "input" },
    ]
  }
}
// 盘点单
export const Type_Count = {
  type: async () => {
    const res = await dictDataList({
      dictType: "stocktake_type",
    })
    return res.map((btn) => {
      return {
        name: btn.dictLabel,
        value: btn.dictValue,
        id: btn.id,
      };
    });
  },
  detailInfoList: () => {
    return [
      { name: "单价", value: "unitPrice", preUnit: "¥" },
      { name: "盘点数量", value: "qty", afterUnit: 'unitName' },
      { name: "盘点金额", value: "amount", preUnit: "¥" },
      { name: "备注", value: "remark" },
    ]
  },
  options: () => {
    return [
      { name: "盘点单价", value: "unitPrice", type: "step", preUnit: "元/", unit: 'unitName' },
      { name: "盘点数量", value: "qty", type: "step", unit: 'unitName' },
      { name: "备注", value: "remark", type: "input" },
    ]
  }
}
// 退货单
export const Type_Return = {
  type: async () => {
    const res = await dictDataList({
      dictType: "loss_case",
    })
    return res.map((btn) => {
      return {
        name: btn.dictLabel,
        value: btn.dictValue,
        id: btn.id,
      };
    });
  },
  detailInfoList: () => {
    return [
      { name: "单价", value: "unitPrice", preUnit: "¥" },
      { name: "数量", value: "qty", afterUnit: 'unitName' },
      { name: "金额", value: "amount", preUnit: "¥" },
      { name: "备注", value: "remark" },
    ]
  },
  options: () => {
    return [
      { name: "退货单价", value: "unitPrice", type: "step", preUnit: "元/", util: 'unitName' },
      { name: "退货数量", value: "qty", type: "step", unit: 'unitName' },
      { name: "备注", value: "remark", type: "input" },
    ]
  }
}
export default {
  In: Type_In,
  Out: Type_Out,
  Count: Type_Count,
  Return: Type_Return
}
